package sgc.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import org.primefaces.event.RowEditEvent;

import sgc.struc.Fact_Header;
import sgc.struc.Fact_Position;
import sgc.struc.MovStock_h;
import sgc.struc.Pord_Header;
import sgc.struc.Pord_Position;

@ManagedBean(name = "verifFactBean")
@RequestScoped
public class VerifFactBean implements Serializable {

	private static final long serialVersionUID = 1L;
	private Fact_Header header;
	private Fact_Position position;
	private List<Fact_Position> positions;
	private DataSource ds;
	private int company_code;
	private String company_name;
	private String user_id;

	public VerifFactBean() {
		try {
			Context ctx = new InitialContext();
			ds = (DataSource) ctx.lookup("java:comp/env/jdbc/sgcweb");
		} catch (NamingException e) {
			e.printStackTrace();
		}
		header = new Fact_Header();
		positions = new ArrayList<Fact_Position>();
		positions.clear();

		FacesContext context = FacesContext.getCurrentInstance();
		CheckUserBean cu = (CheckUserBean) context.getApplication()
				.evaluateExpressionGet(context, "#{checkUserBean}",
						CheckUserBean.class);

		company_code = cu.getUsuario().getCompany_code();
		company_name = cu.getUsuario().getCompany();
		user_id = cu.getUsuario().getName();
	}

	public Fact_Header getHeader() {
		return header;
	}

	public void setHeader(Fact_Header header) {
		this.header = header;
	}

	public Fact_Position getPosition() {
		return position;
	}

	public void setPosition(Fact_Position position) {
		this.position = position;
	}

	public List<Fact_Position> getPositions() {
		return positions;
	}

	public void setPositions(List<Fact_Position> positions) {
		this.positions = positions;
	}

	public void onEdit(RowEditEvent event) {

	}

	public void onCancel(RowEditEvent event) {

	}

	public void save() {

	}
}
